<template>
  <el-dialog 
    v-model="visible" 
    title="今日直播提醒" 
    width="520px" 
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :show-close="false"
    class="live-notification-dialog"
    center
  >
    <div class="notification-content">
      <!-- 图标 -->
      <div class="notification-icon">
        <el-icon size="48" color="#f56c6c">
          <VideoCamera />
        </el-icon>
      </div>
      
      <!-- 提示文本 -->
      <div class="notification-text">
        <h3>您今天有直播课程</h3>
        <p>检测到您今天有安排的直播课程，是否前往直播管理页面开始直播？</p>
      </div>
      
      <!-- 课程信息（可选显示） -->
      <div v-if="courseInfo" class="course-info">
        <div class="course-item">
          <span class="course-label">课程名称：</span>
          <span class="course-value">{{ courseInfo.name }}</span>
        </div>
        <div class="course-item">
          <span class="course-label">开始时间：</span>
          <span class="course-value">{{ courseInfo.startTime }}</span>
        </div>
      </div>
    </div>
    
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="handleCancel" size="large">
          稍后再说
        </el-button>
        <el-button type="primary" @click="handleConfirm" size="large">
          <el-icon class="mr-1"><VideoCamera /></el-icon>
          前往直播
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref, watch, defineProps, defineEmits } from 'vue';
import { VideoCamera } from '@element-plus/icons-vue';

// 定义props
const props = defineProps({
  modelValue: {
    type: Boolean,
    default: false
  },
  courseInfo: {
    type: Object,
    default: null
  }
});

// 定义emits
const emit = defineEmits(['update:modelValue', 'confirm', 'cancel']);

// 响应式数据
const visible = ref(props.modelValue);

// 监听props变化
watch(() => props.modelValue, (newValue) => {
  visible.value = newValue;
});

// 监听visible变化
watch(visible, (newValue) => {
  emit('update:modelValue', newValue);
});

// 处理确认按钮点击
const handleConfirm = () => {
  visible.value = false;
  emit('confirm');
};

// 处理取消按钮点击
const handleCancel = () => {
  visible.value = false;
  emit('cancel');
};
</script>

<style scoped>
/* 对话框样式 */
:deep(.live-notification-dialog .el-dialog) {
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

:deep(.live-notification-dialog .el-dialog__header) {
  padding: 30px 30px 20px;
  border-bottom: 1px solid #f1f5f9;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

:deep(.live-notification-dialog .el-dialog__title) {
  font-size: 20px;
  font-weight: 600;
  color: #1f2937;
  display: flex;
  align-items: center;
  justify-content: center;
}

:deep(.live-notification-dialog .el-dialog__body) {
  padding: 30px;
  background: #ffffff;
}

/* 通知内容样式 */
.notification-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.notification-icon {
  margin-bottom: 20px;
  padding: 20px;
  background: rgba(245, 108, 108, 0.1);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.notification-text {
  margin-bottom: 25px;
}

.notification-text h3 {
  font-size: 24px;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 12px 0;
}

.notification-text p {
  font-size: 16px;
  color: #6b7280;
  margin: 0;
  line-height: 1.6;
}

/* 课程信息样式 */
.course-info {
  background: #f8fafc;
  border-radius: 12px;
  padding: 20px;
  margin-top: 10px;
  width: 100%;
  max-width: 400px;
  border: 1px solid #e2e8f0;
}

.course-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.course-item:last-child {
  margin-bottom: 0;
}

.course-label {
  font-size: 14px;
  color: #6b7280;
  font-weight: 500;
}

.course-value {
  font-size: 14px;
  color: #1f2937;
  font-weight: 600;
}

/* 底部按钮样式 */
.dialog-footer {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding-top: 20px;
}

.dialog-footer .el-button {
  min-width: 120px;
  height: 44px;
  font-size: 16px;
  font-weight: 500;
  border-radius: 8px;
}

/* 主要按钮样式 */
.dialog-footer .el-button--primary {
  background: linear-gradient(135deg, #f56c6c, #e53e3e);
  border: none;
  box-shadow: 0 4px 12px rgba(245, 108, 108, 0.4);
  transition: all 0.3s ease;
}

.dialog-footer .el-button--primary:hover {
  background: linear-gradient(135deg, #e53e3e, #c53030);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(245, 108, 108, 0.5);
}

/* 次要按钮样式 */
.dialog-footer .el-button:not(.el-button--primary) {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #6b7280;
}

.dialog-footer .el-button:not(.el-button--primary):hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #4b5563;
}

/* 图标间距 */
.mr-1 {
  margin-right: 4px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  :deep(.live-notification-dialog) {
    width: 90% !important;
  }
  
  .notification-text h3 {
    font-size: 20px;
  }
  
  .notification-text p {
    font-size: 14px;
  }
  
  .dialog-footer {
    flex-direction: column;
    gap: 12px;
  }
  
  .dialog-footer .el-button {
    width: 100%;
  }
}
</style>
